package it.lupo.model;

import java.util.List;

import javax.persistence.AttributeOverride;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;

 

@Entity
@Table(name="lupo.users")
@AttributeOverride(name="id",column=@Column(name="username"))
public class User extends BaseEntity<String>{

	private static final long serialVersionUID = -5155358031038228543L;
	
	public enum Role {ADMIN,DEFAULT}
	
	@Column
	@NotNull
	private String password;
	@Column
	private String name;
	@Column
	private String surname;
	@Column(length=1)
	private Role role;
	
	@OneToMany(mappedBy="operator",fetch=FetchType.LAZY)
	private List<Conferment> conferment;
	@OneToMany(mappedBy="operator",fetch=FetchType.LAZY)
	private List<BarCode> barcodes;
	
	public User(){}
	
	public User(String username, String password, Role role) {
		super(username);
		this.password = password;
		this.role = role;
	}
	
	
	
	public User( String username, String password, String name,
			String surname, Role role) {
		super(username);
		this.password = password;
		this.name = name;
		this.surname = surname;
		this.role = role;
	}



	public String getUsername() {
		return getId();
	}
	public void setUsername(String username) {
		setId(username);
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	public Role getRole() {
		return role;
	}
	public void setRole(Role role) {
		this.role = role;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getSurname() {
		return surname;
	}
	public void setSurname(String surname) {
		this.surname = surname;
	}



	@Override
	public String toString() {
		return "User [password=" + password + ", name=" + name + ", surname="
				+ surname + ", role=" + role + ", getId()=" + getId() + "]";
	}
	 
	
	

	

}
